package com.prs.crm.vo.report;

import java.sql.Date;
import java.text.SimpleDateFormat;

import org.apache.commons.beanutils.PropertyUtils;

import com.prs.crm.report.ReportCell;
import com.prs.crm.report.ReportTable;


public class PDFExport implements Export{

	public ExportResult export(ReportTable table)
	{
		return null;
	}
	
	private void renderHeader(ReportTable table)
	{
		for (ReportCell cell : table.getCells())
		{
			cell.getName();
		}
	}
	
	private void renderBody(ReportTable table) throws Exception
	{
		String text;
		for (Object entity : table.getDataSource())
		{
			for (ReportCell cell : table.getCells())
			{
				Object value  = PropertyUtils.getProperty(entity, cell.getProperty());
				text = value.toString();
				if (cell.getFormat()!=null)
				{
						if (PropertyUtils.getPropertyType(entity, cell.getProperty()).equals(Date.class))
						{
							SimpleDateFormat format = new SimpleDateFormat(cell.getFormat());
							text = format.format((Date)value);
						}
				}
			}
		}
	}
}
